package com.aixi.desktop.utils

import android.app.AlarmManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import androidx.core.app.AlarmManagerCompat
import com.aixi.desktop.glance.MyWidgetApp


fun Context.sendMyWidgetAppUpdate(netAlertTime: Long = System.currentTimeMillis()) {
    val intent = Intent(MyWidgetApp.ACTION)
    intent.`package` = packageName

    AlarmManagerCompat.setExact(
        getSystemService(Context.ALARM_SERVICE) as AlarmManager,
        AlarmManager.RTC,
        netAlertTime, PendingIntent.getBroadcast(
            this, 1000,
            intent, PendingIntent.FLAG_IMMUTABLE
        )
    )
}
